package com.own.component.store.core.util.base;

import com.own.component.store.core.exception.StoreException;
import com.own.constant.ConstantCommon;

/**
 * StoreKeyUtil
 *
 * @author chenxueli
 * @date 2023-07-21 10:19:18
 */
public final class StoreKeyUtil {

    /**
     * 更新键
     *
     * @param module 模块名
     * @param key    键名
     * @return 新的键名
     */
    public static String buildKey(final String module, final String key) {
        var resultKey = ConstantCommon.REDIS_PREFIX + module + ConstantCommon.REDIS_SEPARATE + key;
        if (key.contains(ConstantCommon.STAR)) {
            resultKey += key.replace(ConstantCommon.STAR, "");
        }
        if (key.isEmpty()) {
            throw new StoreException();
        }
        return resultKey;
    }

}
